package com.atguigu.srb.oss.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2 //开启Swagger2功能
public class Swagger2Config {

    @Bean
    public Docket adminDocket(){

        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .groupName("OssApi")
                .apiInfo(getApiInfo())
                .select()
                .paths(Predicates.and(PathSelectors.regex("/api/oss/.*")))
                .build();

        return docket;
    }

    public ApiInfo getApiInfo(){

        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("文件存储接口文档")
                .description("此文档描述了文件存储接口")
                .version("1.0")
                .contact(new Contact("lsy","看不懂就算了","不告诉你"))
                .build();
        return apiInfo;
    }
}